﻿<%@ Page Language="C#" MasterPageFile="~/Layout.Master" AutoEventWireup="true" CodeBehind="editRooms.aspx.cs" Inherits="PT.WebForm5" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="cpContent" ContentPlaceHolderID="cpContent" runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="id" 
        DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no data records to display." Height="100%" 
        Width="100%" BorderStyle="None" CssClass="grid">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" 
                SortExpression="id" >
            <ItemStyle Width="10%" />
            </asp:BoundField>
            <asp:BoundField DataField="name" HeaderText="Opis" SortExpression="name" >
            <ItemStyle Width="60%" />
            </asp:BoundField>
            <asp:BoundField DataField="size" HeaderText="Rozmiar" SortExpression="size" >
            <ItemStyle Width="10%" />
            </asp:BoundField>
            <asp:BoundField DataField="cost" HeaderText="Cena za dobę" 
                SortExpression="cost" >
            <ItemStyle Width="15%" />
            </asp:BoundField>
            <asp:CommandField CancelText="Anuluj" EditText="Edytuj" ShowEditButton="True" 
                UpdateText="Zapisz" >
            <ItemStyle Width="5%" />
            </asp:CommandField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:HotelConnectionString1 %>" 
        DeleteCommand="DELETE FROM [Rooms] WHERE [id] = @id" 
        InsertCommand="INSERT INTO [Rooms] ([size], [cost], [name]) VALUES (@size, @cost, @name)" 
        ProviderName="<%$ ConnectionStrings:HotelConnectionString1.ProviderName %>" 
        SelectCommand="SELECT [id], [size], [cost], [name] FROM [Rooms]" 
        UpdateCommand="UPDATE [Rooms] SET [size] = @size, [cost] = @cost, [name] = @name WHERE [id] = @id">
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="size" Type="Int32" />
            <asp:Parameter Name="cost" Type="Int32" />
            <asp:Parameter Name="name" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="size" Type="Int32" />
            <asp:Parameter Name="cost" Type="Int32" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
